import { defineStore } from 'pinia'
import { THEME_PRO } from '@/enums/cacheEnum'
import { createStorage } from '@/utils/storage'
import { Theme } from '@/config'

const Storage = createStorage()

export const useThemeStore = defineStore('app-theme', {
  state: () => ({
    themePro: Storage.get(THEME_PRO, Theme.theme)
  }),
  actions: {
    /**
     * 设置菜单数据
     */
    setTheme(type = this.themePro) {
      this.themePro = type
      Storage.set(THEME_PRO, type, null)
      document.body.setAttribute('arco-theme', type)
    }
  }
})
